package com.wm.service.imp;

import java.util.List;

import com.wm.bean.Address;
import com.wm.dao.AddressDAO;
import com.wm.service.AddressService;

/**
 * @author yangbo
 *
 * 2013-1-6
 */
public class AddressServiceImp implements AddressService {

	private AddressDAO addressDAO;
	
	public AddressDAO getAddressDAO() {
		return addressDAO;
	}

	public void setAddressDAO(AddressDAO addressDAO) {
		this.addressDAO = addressDAO;
	}

	/**
	 * 保存
	 * @param a
	 * @return
	 */
	public Address saveAddress(Address a){
		return this.getAddressDAO().saveAddress(a);
	}
	
	/**
	 * 修改
	 * @param a
	 * @return
	 */
	public Address updateAddress(Address a){
		return this.getAddressDAO().updateAddress(a);
	}
	
	/**
	 * 删除
	 * @param a
	 */
	public void removeAddress(long id){
		Address a = this.getAddressDAO().findAddressById(id);
		this.getAddressDAO().removeAddress(a);
	}
	
	/**
	 * 根据ID查询
	 * @param id
	 * @return
	 */
	public Address findAddressById(long id){
		return this.getAddressDAO().findAddressById(id);
	}
	
	/**
	 * 根据用户ID查询
	 * @param userId
	 * @return
	 */
	public List findAddressByUserId(long userId){
		return this.getAddressDAO().findAddressByUserId(userId);
	}
	
	/**
	 * 查询默认地址
	 * @return
	 */
	public Address findAddressByIsUserIdDefault(long userId){
		return this.getAddressDAO().findAddressByIsUserIdDefault(userId);
	}
}
